package liu.de.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.Instant;


/**
 * @author liude
 */
@Entity(name = "rating")
@Data
@NoArgsConstructor
@SuppressWarnings("unused")
public class RatingDO {
    @EmbeddedId
    private RatingId ratingId;

    public RatingDO(int userId, int movieId, BigDecimal rate, Instant datetime) {
        this.ratingId = new RatingId(userId, movieId, rate, datetime);
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    @Embeddable
    private static class RatingId implements Serializable {
        private static final long serialVersionUID = 8729850194725692123L;

        private Integer userId;

        private Integer movieId;

        private BigDecimal rate;

        @Column(name = "rate_timestamp")
        private Instant timestamp;
    }
}


